using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using LibHuman;

namespace Human
{
    
    public class pPrint: cPrint
    {
        frmReport f;
        frmMain2005 f_m;//= new frmMain2005();
        string user_dn = "";
        public pPrint(string mmyy,string s_userdn)
        {
            s_mmyy = mmyy;
            user_dn = s_userdn;
        }

        public pPrint(frmMain2005 f1 )
        {
            f_m = f1;
        }
        
        public void Print(AccessData mDB, DataSet ds, string m_tile, string m_report, bool n_doc, int sl)
        {
            f = new frmReport(mDB, ds, m_tile, m_report, n_doc, sl,user_dn);
            f.MdiParent = f_m;
            f.TopMost = true;
            f.Show();
        }

        string s_mmyy = "";
        public void Printer(AccessData m, DataSet ds, string ngaythangnam, string ngayin, string msg, string bophan, string report, int kieu, int copy,string mmyy)
        {
            s_mmyy = mmyy;
            try
            {
                ReportDocument oRpt = new ReportDocument();
                oRpt.Load("report\\" + report);
                oRpt.SetDataSource(ds);
                oRpt.DataDefinition.FormulaFields["SoYTe"].Text = "'" + m.Syte().ToUpper() + "'";
                oRpt.DataDefinition.FormulaFields["BenhVien"].Text = "'" + m.Tenbv.ToUpper() + "'";
                oRpt.DataDefinition.FormulaFields["title"].Text = "'" + msg + "'";
                oRpt.DataDefinition.FormulaFields["ngaythangnam"].Text = "'" + ngaythangnam + "'";
                oRpt.DataDefinition.FormulaFields["ngayin"].Text = "'" + ngayin + "'";
                oRpt.DataDefinition.FormulaFields["giamdoc"].Text = " '" + m.Giamdoc().ToString() + "' ";
                oRpt.DataDefinition.FormulaFields["bophan"].Text = "'" + bophan + "'";
                oRpt.DataDefinition.FormulaFields["diachi"].Text = "'" + m.Diachi().ToString() + "'";

                oRpt.PrintOptions.PaperSize = PaperSize.DefaultPaperSize;
                oRpt.PrintOptions.PaperOrientation = (kieu == 1) ? PaperOrientation.Portrait : PaperOrientation.Landscape;
                oRpt.PrintToPrinter(copy, false, 0, 0);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
    }
}
